﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ueEngine.Biz.Inf.Entities;
using ueEngine.Biz.Inf.LogicEntity.SupportData;

namespace ueEngine.Biz.Inf.LogicEntity
{
    public class ShortDiscussModel : IAccessible<ShortDiscuss,ShortDiscussModel>
    {
        #region self
        public int Id { get; set; }
        /// <summary>
        /// 关联的信息资源Id
        /// </summary>
        public int ReferenceId { get; set; }
        /// <summary>
        /// 关联的模块代码
        /// </summary>
        public ReferenceCode ReferenceCode { get; set; }
        /// <summary>
        /// 编写时间
        /// </summary>
        public DateTime WriteDate { get; set; }
        /// <summary>
        /// 作者
        /// </summary>
        public string Author { get; set; }
        /// <summary>
        /// 文本
        /// </summary>
        public string Content { get; set; }
        /// <summary>
        /// 赞同次数
        /// </summary>
        public int Up { get; set; }
        /// <summary>
        /// 反对次数
        /// </summary>
        public int Down { get; set; }
        /// <summary>
        /// 评价
        /// </summary>
        public Appraise Appraise { get; set; }

        public bool IsDelete { get; set; }
        #endregion
        protected override void Covariant(ShortDiscuss dbModel)
        {
            this.Author = dbModel.Author;
            this.Content = dbModel.Content;
            this.Id = dbModel.Id;
            this.ReferenceCode = (ReferenceCode)dbModel.ReferenceCode;
            this.ReferenceId = dbModel.ReferenceId;
            this.WriteDate = dbModel.WriteDate;
            this.Up = dbModel.Up;
            this.Down = dbModel.Down;
            this.Appraise = (Appraise)dbModel.Appraise;
            this.IsDelete = dbModel.IsDelete;
        }
        protected override ShortDiscuss Inverter(ShortDiscussModel model)
        {
            return new ShortDiscuss()
            {
                Author = model.Author,
                Content = model.Content,
                Id = model.Id,
                ReferenceCode = (int)model.ReferenceCode,
                ReferenceId = model.ReferenceId,
                WriteDate = model.WriteDate,
                Appraise = (int)model.Appraise,
                Down = model.Down,
                Up = model.Up,
                IsDelete = model.IsDelete
            };
        }
    }
}
